package org.ycx.upms.dao.auto;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.ycx.upms.dao.model.SecUserRole;
import org.ycx.upms.dao.model.SecUserRoleExample;

import java.util.List;

public interface SecUserRoleMapper {
    @SelectProvider(type=SecUserRoleSqlProvider.class, method="countByExample")
    long countByExample(SecUserRoleExample example);

    @DeleteProvider(type=SecUserRoleSqlProvider.class, method="deleteByExample")
    int deleteByExample(SecUserRoleExample example);

    @Delete({
        "delete from sec_user_role",
        "where USER_ID = #{userId,jdbcType=INTEGER}",
          "and ROLE_ID = #{roleId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(@Param("userId") Integer userId, @Param("roleId") Integer roleId);

    @Insert({
        "insert into sec_user_role (USER_ID,ROLE_ID)",
        "values (#{userId},#{roleId})"
    })
    int insert(SecUserRole record);

    @InsertProvider(type=SecUserRoleSqlProvider.class, method="insertSelective")
    int insertSelective(SecUserRole record);

    @SelectProvider(type=SecUserRoleSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="USER_ID", property="userId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="ROLE_ID", property="roleId", jdbcType=JdbcType.INTEGER, id=true)
    })
    List<SecUserRole> selectByExample(SecUserRoleExample example);

    @UpdateProvider(type=SecUserRoleSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SecUserRole record, @Param("example") SecUserRoleExample example);

    @UpdateProvider(type=SecUserRoleSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") SecUserRole record, @Param("example") SecUserRoleExample example);
}